<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		6.从键盘分别输入年、月、日，判断这一天是当年的第几天
		 
		   注：判断一年是否是闰年的标准：
		       1）可以被4整除，但不可被100整除
		       2）可以被400整除
		年<input type="text" id="input_year" value="2020"/>
		月<input type="text" id="input_month" value="2"/>
		日<input type="text" id="input_day" value="19"/>
		<button type="button" onclick="cal()">计算</button>
		</br>
		<span>结果</span>
		<script type="text/javascript">
			function cal() {
				let input_year = document.getElementById("input_year");
				let input_month = document.getElementById("input_month");
				let input_day = document.getElementById("input_day");
				let year = parseInt(input_year.value);
				let month = parseInt(input_month.value);
				console.log(typeof(month));
				let day = parseInt(input_day.value);
				switch(month) {
					case 12:
						day += 30;
					case 11:
						day += 31;
					case 10:
						day += 30;
					case 9:
						day += 31;
					case 8:
						day += 31;
					case 7:
						day += 30;
					case 6:
						day += 31;
					case 5:
						day += 30;
					case 4:
						day += 31;
					case 3:
						if(isRun(year)) {
							day += 29;
						}else{
							day += 28;
						}
						
					case 2:
						console.log(2);
						day += 31;
					case 1:
				}
				console.log(day);
				let span = document.getElementsByTagName("span")[0];
				span.innerText = "是第" + day + "天";
			}
			
			function isRun(year) {
				if((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
					return true;
				}
				
				return false;
			}
		</script>
	</body>
</html>
